﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace TriviaFinal
{
	public partial class Form1 : Form
	{
		GameControl gameControl;
		private int answer;
		bool correct;
		//List<Question> questions = new List<Question>();
		//string[] textFiles = { "Question.txt"};

		public Form1()
		{
			InitializeComponent();
			
			gameControl = new GameControl();
			int textIndex = 0;
			//ReadFromFile(textIndex);
			
		}
		private void Bsubmit_Click(object sender, EventArgs e)
		{
			Rbinvisible.Checked = true;

			if (RBanswerA.Checked)
				answer = 1;
			else if (RBanswerB.Checked)
				answer = 2;
			else if (RBanswerC.Checked)
				answer = 3;
			else if (RBanswerD.Checked)
				answer = 4;

			correct = gameControl.QuestionCorrect(answer);
			if (correct == true)
			{
				MessageBox.Show("Correct!");
			}
			else
			{
				MessageBox.Show("Incorrect :C");
			}
			if (gameControl.success == false)
			{
				gameControl.Trivia();
			}
			else
			{
				this.Close();
			}
		}

		private void Rbinvisible_CheckedChanged(object sender, EventArgs e)
		{
			if (Bsubmit.Enabled == false)
				Bsubmit.Enabled = true;
			else
				Bsubmit.Enabled = false;
		}

		public void GiveTrivia()
		{
			//string question, string answer1, string answer2, string answer3, string answer4, string qRequired, string qCorrect, string qLeft
			RBanswerA.Text = gameControl.questionInformation[1];
			RBanswerB.Text = gameControl.questionInformation[2];
			RBanswerC.Text = gameControl.questionInformation[3];
			RBanswerD.Text = gameControl.questionInformation[4];
			Lquestion.Text = gameControl.questionInformation[0];
			Lqleft.Text = gameControl.questionInformation[7];
			Lrequired.Text = gameControl.questionNumber.ToString();
			Lcorrect.Text = gameControl.questionInformation[6];

		}

		private void Form1_Load(object sender, EventArgs e)
		{

		}

		

		//private void textBox1_TextChanged(object sender, EventArgs e)
		//{
		//	Question questions = questions[comboBox1.SelectedIndex];

		//	textBox1.Text =questions.set;
		//}

		//private void ReadFromFile(int index)
		//{
		//	//this will make a connection to the file on the 
		//	//hard disk
		//	StreamReader sr = new StreamReader(textFiles[index]);

		//	//this will read one line of data from the file
		//	string input = sr.ReadLine();

		//	//setup a while loop so that the code keeps looping 
		//	//thru the file until it reaches the end of the file
		//	while (input != null)
		//	{
		//		//string to array to hold the individual element data
		//		//use the Split method to divide the elements
		//		string[] data = input.Split(',');
		//		//bool[] connections = new bool[6];

		//		//assigning and convert element data
		//		string question = data[0];
		//		string answera = data[1];
		//		string answerb = data[2];
		//		string answerc = data[3];
		//		string answerd = data[4];
				
		//		//create the element object
		//		Question questions = new Question (question, answera, answerb, answerc, answerd)
				

		//		//add to the List<Element> object
		//		//questions.Add(quesitons);

		//		//add the name of the element to the listbox object
		//		//listBoxElementNames.Items.Add(name);

		//		//read from the file again to see if there is still 
		//		//some info that needs to be read in
		//		input = sr.ReadLine();
		//	}

		//	//this will close the link to the file on the hard disk
		//	sr.Close();
		//}


		//private void Form1_Load(object sender, EventArgs e)
		//{
		
		//}

		//private void radioButton1_CheckedChanged(object sender, EventArgs e)
		//{
		
		//}

		

	}
}
